(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 8.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[     11255,        356]
NotebookOptionsPosition[     10961,        341]
NotebookOutlinePosition[     11353,        358]
CellTagsIndexPosition[     11310,        355]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"\[CapitalDelta]t", " ", "=", "1"}], ";", " ", 
   RowBox[{"\[CapitalDelta]x", "=", "1"}], ";", " ", 
   RowBox[{"\[CapitalDelta]y", "=", "1"}], ";"}], " ", 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"\[Epsilon]", "[", 
    RowBox[{"i_", ",", "j_"}], "]"}], ":=", "1"}], ";", " ", 
  RowBox[{
   RowBox[{"\[Sigma]", "[", 
    RowBox[{"i_", ",", "j_"}], "]"}], ":=", "1"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"\[Mu]", "[", 
    RowBox[{"i_", ",", "j_"}], "]"}], ":=", "1"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CP", "[", 
    RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
   FractionBox[
    RowBox[{"1", "-", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", 
        RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", 
        RowBox[{"i", ",", "j"}], "]"}]}]]}], 
    RowBox[{"1", "+", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", 
        RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", 
        RowBox[{"i", ",", "j"}], "]"}]}]]}]]}], ";", " ", 
  RowBox[{
   RowBox[{"CQ", "[", 
    RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
   FractionBox[
    FractionBox[
     RowBox[{"\[CapitalDelta]t", " "}], 
     RowBox[{"\[Mu]", "[", 
      RowBox[{"i", ",", "j"}], "]"}]], 
    RowBox[{"1", "+", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", 
        RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", 
        RowBox[{"i", ",", "j"}], "]"}]}]]}]]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CA", "[", 
     RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
    FractionBox[
     RowBox[{"1", "-", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", 
         RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", 
         RowBox[{"i", ",", "j"}], "]"}]}]]}], 
     RowBox[{"1", "+", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", 
         RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", 
         RowBox[{"i", ",", "j"}], "]"}]}]]}]]}], ";", " ", 
   RowBox[{
    RowBox[{"CB", "[", 
     RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
    FractionBox[
     FractionBox[
      RowBox[{"\[CapitalDelta]t", " "}], 
      RowBox[{"\[Epsilon]", "[", 
       RowBox[{"i", ",", "j"}], "]"}]], 
     RowBox[{"1", "+", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", 
         RowBox[{"i", ",", "j"}], "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", 
         RowBox[{"i", ",", "j"}], "]"}]}]]}]]}], ";"}], "\[IndentingNewLine]", 
  RowBox[{"(*", " ", 
   RowBox[{"For", " ", "TE"}], " ", "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetEx", "[", 
    RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CA", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"Ex", "[", 
      RowBox[{"i", ",", "j", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "+", 
    RowBox[{
     RowBox[{"CB", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Hz", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "+", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Hz", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "-", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]y"], 
      ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetEy", "[", 
    RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"CA", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"Ey", "[", 
      RowBox[{"i", ",", "j", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "-", 
    RowBox[{
     RowBox[{"CB", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Hz", "[", 
         RowBox[{
          RowBox[{"i", "+", 
           FractionBox["1", "2"]}], ",", "j", ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Hz", "[", 
         RowBox[{
          RowBox[{"i", "-", 
           FractionBox["1", "2"]}], ",", "j", ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], 
      ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"GetHz", "[", 
     RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", "\[IndentingNewLine]",
     "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
      RowBox[{"CP", "[", 
       RowBox[{"i", ",", "j"}], "]"}], "*", 
      RowBox[{"Hz", "[", 
       RowBox[{"i", ",", "j", ",", 
        RowBox[{"n", "-", "1"}]}], "]"}]}], "-", 
     RowBox[{
      RowBox[{"CQ", "[", 
       RowBox[{"i", ",", "j"}], "]"}], "*", 
      RowBox[{"(", 
       RowBox[{
        FractionBox[
         RowBox[{
          RowBox[{"Ey", "[", 
           RowBox[{
            RowBox[{"i", "+", 
             FractionBox["1", "2"]}], ",", "j", ",", 
            RowBox[{"n", "-", 
             FractionBox["1", "2"]}]}], "]"}], "-", 
          RowBox[{"Ey", "[", 
           RowBox[{
            RowBox[{"i", "-", 
             FractionBox["1", "2"]}], ",", "j", ",", 
            RowBox[{"n", "-", 
             FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], "-", 
        FractionBox[
         RowBox[{
          RowBox[{"Ex", "[", 
           RowBox[{"i", ",", 
            RowBox[{"j", "+", 
             FractionBox["1", "2"]}], ",", 
            RowBox[{"n", "-", 
             FractionBox["1", "2"]}]}], "]"}], "-", 
          RowBox[{"Ex", "[", 
           RowBox[{"i", ",", 
            RowBox[{"j", "-", 
             FractionBox["1", "2"]}], ",", 
            RowBox[{"n", "-", 
             FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]y"]}], 
       ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
  RowBox[{"(*", " ", 
   RowBox[{"For", " ", "TM"}], " ", "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetHx", "[", 
    RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CP", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"Hx", "[", 
      RowBox[{"i", ",", "j", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "-", 
    RowBox[{
     RowBox[{"CQ", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Ez", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "+", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Ez", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "-", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]y"], 
      ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetHy", "[", 
    RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CP", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"Hx", "[", 
      RowBox[{"i", ",", "j", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "+", 
    RowBox[{
     RowBox[{"CQ", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Ez", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "+", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Ez", "[", 
         RowBox[{"i", ",", 
          RowBox[{"j", "-", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], 
      ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetEz", "[", 
    RowBox[{"i_", ",", "j_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CA", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"Ez", "[", 
      RowBox[{"i", ",", "j", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "+", 
    RowBox[{
     RowBox[{"CB", "[", 
      RowBox[{"i", ",", "j"}], "]"}], "*", 
     RowBox[{"(", 
      RowBox[{
       FractionBox[
        RowBox[{
         RowBox[{"Hy", "[", 
          RowBox[{
           RowBox[{"i", "+", 
            FractionBox["1", "2"]}], ",", "j", ",", 
           RowBox[{"n", "-", 
            FractionBox["1", "2"]}]}], "]"}], "-", 
         RowBox[{"Hy", "[", 
          RowBox[{
           RowBox[{"i", "-", 
            FractionBox["1", "2"]}], ",", "j", ",", 
           RowBox[{"n", "-", 
            FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], "-", 
       FractionBox[
        RowBox[{
         RowBox[{"Hx", "[", 
          RowBox[{"i", ",", 
           RowBox[{"j", "+", 
            FractionBox["1", "2"]}], ",", 
           RowBox[{"n", "-", 
            FractionBox["1", "2"]}]}], "]"}], "-", 
         RowBox[{"Hx", "[", 
          RowBox[{"i", ",", 
           RowBox[{"j", "-", 
            FractionBox["1", "2"]}], ",", 
           RowBox[{"n", "-", 
            FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]y"]}], 
      ")"}]}]}]}], ";"}]}], "Input",
 CellChangeTimes->{
  3.560304720685964*^9, 3.560304864365182*^9, {3.56030491153288*^9, 
   3.5603049241886034`*^9}, {3.5603049623327856`*^9, 
   3.5603050005559716`*^9}, {3.5603050605724044`*^9, 
   3.5603053161140203`*^9}, {3.5603055388455596`*^9, 
   3.5603055779256144`*^9}, {3.560305683266774*^9, 3.5603057474268637`*^9}, {
   3.560305792896928*^9, 3.560305823446971*^9}, {3.5603058595670214`*^9, 
   3.5603059746071825`*^9}, {3.5603062408911715`*^9, 3.560306469543892*^9}}]
},
WindowSize->{1071, 743},
WindowMargins->{{87, Automatic}, {Automatic, 34}},
Magnification->1.4000000953674316`,
FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (2011\:5e743\:670815\
\:65e5)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 10400, 319, 1067, "Input"]
}
]
*)

(* End of internal cache information *)
